<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>


<nav class="navbar navbar-inverse navbar-expand-lg" role="navigation">
  <a class="navbar-brand" href="#">选课管理系统</a>
  <button type="button" class="navbar-toggler" data-toggle="collapse" data-target="#navbar-collapse-01"></button>
  <div class="collapse navbar-collapse" id="navbar-collapse-01">
  <ul class="nav navbar-nav mr-auto">
	<li><a href="/StudentInfo/StudentHandler/queryStudentCourse"><strong>选课</strong></a>
	<li><a href="/StudentInfo/StudentHandler/selcouresult"><strong>查看选课结果</strong></a>
	<li><a href="/StudentInfo/StudentHandler/endcourse"><strong>查看已修课程</strong></a>
	<li><a href="/StudentInfo/StudentHandler/queryvitastu"><strong>管理个人信息</strong></a>
  </ul>
  <p class="navbar-text navbar-right">你好！${sessionScope.sname}
	  <a href="/StudentInfo/LoginHandler/studentlogout" class="navbar-link" style="padding-left: 1em" href="#"> 注销</a>
  </p>
  </div>
</nav>

<script>
	window.onload = function () {
		let display = readCookie("display"); // 如果cookie过期，则display为空；

		// 如果cookie未过期，刷新页面时重置过期时间
		if (display == "none") {
			refreshCookieTime();
		}
	}
	function readCookie (name) {
		let cookieValue = "";
		const search = name + "=";
		if (document.cookie.length > 0) {
			offset = document.cookie.indexOf(search);
			if (offset != -1) {
				offset += search.length;
				end = document.cookie.indexOf(";", offset);
				if (end == -1) {
					end = document.cookie.length;
				}
				cookieValue = unescape(document.cookie.substring(offset, end))
			}
		}
		return cookieValue;
	}

	function refreshCookieTime() {
		const millisecond = new Date().getTime();
		const expiresTime = new Date(millisecond + 60 * 1000 * 30);
		document.cookie = "display=none;expires=" + expiresTime.toUTCString();
	}

</script>